<?php

namespace app\api\controller;

use think\Controller;

class Teacher extends Controller
{
    //名师规划
    public function teacher()
    {
        $teacher = model('common/Teacher')
            -> where(['classify'=>1,'status'=>1])
            -> field('id,tname,position,sex,region,recome,profile,photo')
            -> limit(2)
            -> select();
        foreach($teacher as $v){
            if ($v->sex==1){
                $v->sex = '男';
            } else {
                $v->sex = '女';
            }
        }
        if ($teacher){
            return json(['code'=>100,'mag'=>'请求成功','data'=>$teacher]);
        } else {
            return json(['code'=>404,'msg'=>'请求失败！']);
        }
    }

    //名师展望
    public function teacher_list()
    {
        $teacher = model('common/Teacher')
            -> where(['classify'=>1,'status'=>1])
            -> field('id,tname,position,sex,region,recome,profile,photo')
            -> select();
        foreach($teacher as $v){
            if ($v->sex==1){
                $v->sex = '男';
            } else {
                $v->sex = '女';
            }
        }
        if ($teacher){
            return json(['code'=>100,'mag'=>'请求成功','data'=>$teacher]);
        } else {
            return json(['code'=>404,'msg'=>'请求失败！']);
        }
    }

    //专业视界
    public function teacher_lists()
    {
        $teacher = model('common/Teacher')
            -> where(['classify'=>2,'status'=>1])
            -> field('id,tname,major,position,photo')
            -> select();
        if ($teacher){
            return json(['code'=>100,'mag'=>'请求成功','data'=>$teacher]);
        } else {
            return json(['code'=>404,'msg'=>'请求失败！']);
        }
    }
}
